package com.example.nep.controller;

import com.example.nep.base.R;
import com.example.nep.model.GridCity;
import com.example.nep.model.GridProvince;
import com.example.nep.service.IGridCityService;
import com.example.nep.service.IGridProvinceService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: 韩建平
 * @Description: TODO
 * @DateTime: 2024/4/10 10:32
 **/
@CrossOrigin
@RestController
@RequestMapping("province")
public class ProvinceCityController {
    @Resource
    private IGridCityService cityService;
    @Resource
    private IGridProvinceService provinceService;
    @GetMapping("findProvinceAll")
    public R findProvinceAll(){
        List<GridProvince> list = provinceService.list();
        if (list!=null&&list.size()>0){
            return R.ok().setResult("province",list);
        }else {
            return R.error();
        }
    }
    @GetMapping("city")
    public R findCityAll(@RequestParam("provinceId") Integer id){
        List<GridCity> list=cityService.findCityAll(id);
        if (list!=null&&list.size()>0){
            return R.ok().setResult("city",list);
        }else {
            return R.error();
        }
    }
//    @PostMapping("insert")
//    public R insert(@RequestBody )
}
